<template>
  <vue-content>
    <vue-header>
      <!-- <div style="float:right">
        <vue-header-form class="headerFrom">
          <el-form :inline="true" :model="formFilter" ref="formFilter">
            <el-form-item>
            </el-form-item>
          </el-form>
        </vue-header-form>
      </div> -->
    </vue-header>
    <vue-body>
      <el-table
      	v-loading.body="loading"
        :data="tableData"
        border
        style="width: 100%">
        <el-table-column
          prop="complainUserName"
          width="100px"
          label="用户名称">
        </el-table-column>
        <el-table-column
          prop="complainTypeName"
          width="260px"
          label="	留言类型">
        </el-table-column>
        <el-table-column
          prop="complainPhone"
          width="130px"
          label="留言手机号">
        </el-table-column>
        <el-table-column
          prop="complainDescribe"
          label="留言描述">
        </el-table-column>
        <el-table-column
        width="100px"
          label="状态">
          <template slot-scope="scope">
            {{ scope.row.status | status }}
          </template>
        </el-table-column>
         <el-table-column label="操作" width="110px">
          <template slot-scope="scope">
            <el-button
              size="mini"
              :disabled="scope.row.status == '02'"
              @click="handleOperation(scope.row, tableData)">留言受理</el-button>
          </template>
      </el-table-column>
      </el-table>
    </vue-body>
     <vue-footer style="padding: 5px 0;margin: 0 -5px;float:right;">
      <el-pagination
        :current-page.sync="currentPage"
        :page-size="10"
        layout="total, prev, pager, next"
        :total="pageSize">
      </el-pagination>
    </vue-footer>
  </vue-content>
</template>

<script>
  import AuthStorage from '@/services/storage.js'
  import {complainInfoList,operationComplain} from '@/services/reports'
  import {RequestError} from '@/services/errors'
  import {deepClone} from '@/utilities/object'
  export default {
    name: 'sp-opera',
    components: {},
    data: () => ({
      tableData: [],
      currentPage: 1,
      pageSize: 10,
      formFilter: {
      },
      loading: false,
      CategoryList:[],
      view: '',
      ifShow:false
    }),
    methods: {
      async loadData () {
        this.loading = true
        try {
          let data = await complainInfoList(Object.assign({currentPage: this.currentPage},{perPage:10},this.formFilter))
          // debugger
          this.tableData = data.data
          this.pageSize = parseInt(data.totalResult)
        } catch (e) {
          if (e instanceof RequestError) {
            this.$alert(e.message, '提示', {
              type: 'error',
              confirmButtonText: '确定'
            })
          } else {
            throw e
          }
        }
        this.loading = false
      },
      async handleOperation (data) {
        try {
          await operationComplain({complainNo:data.complainNo})
          this.$message({
            type: 'success',
            message: '成功'
          })
          this.loadData()
        } catch (e) {
          if (e instanceof RequestError) {
            this.$alert(e.message, '提示', {
              type: 'error',
              confirmButtonText: '确定'
            })
          } else {
            throw e
          }
        }
      },
    },
    watch: {
      currentPage (newVal) {
        this.loadData(newVal)
      }
    },
    filters: {
      status (value) {
      	//发券途径
        return {'01': '已提交 ','02': '已受理'}[value]
      },
    },
    created () {
      this.loadData()
    }
  }
</script>
